<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AccountPaymentOrder extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('account_payment_order', ['comment' => '付款单表']);
        $table->addColumn('no', 'string', ['limit' => 32, 'comment' => '付款单号', 'default' => ''])
            ->addColumn('company_id', 'integer', ['limit' => 10, 'comment' => '公司id', 'default' => 0])
            ->addColumn('handler_id', 'integer', ['limit' => 10, 'comment' => '处理人id', 'default' => 0])
            ->addColumn('payee_id', 'integer', ['limit' => 10, 'comment' => '收款人id', 'default' => 0])
            ->addColumn('payee_type', 'integer', ['limit' => 1, 'comment' => '收款者类型 1门店 2经销商', 'default' => 0])
            ->addColumn('channel','string', ['limit' => 32, 'comment' => '支付渠道信息', 'default' => ''])
            ->addColumn('status', 'integer', ['limit' => 1, 'comment' => '状态 1:待审核 2:已审核 3:异常', 'default' => 0])
            ->addColumn('trade_no', 'string', ['limit' => 32, 'comment' => '支付单号', 'default' => ''])
            ->addColumn('amount', 'decimal', ['precision' => 10, 'scale' => 2, 'comment' => '付款金额', 'default' => 0.00])
            ->addColumn('remark', 'string', ['limit' => 255, 'comment' => '备注', 'default' => ''])
            ->addColumn('voucher', 'string', ['limit' => 255, 'comment' => '凭证', 'default' => ''])
            ->addColumn('create_time', 'integer', ['limit' => 10, 'comment' => '创建时间', 'default' => 0])
            ->addColumn('update_time', 'integer', ['limit' => 10, 'comment' => '更新时间', 'default' => 0])
            ->addColumn('delete_time', 'integer', ['limit' => 10, 'comment' => '删除时间', 'default' => 0])
            ->addIndex('company_id')
            ->addIndex('handler_id')
            ->addIndex('payee_id')
            ->addIndex('payee_type')
            ->save();
    }
}
